unit Decryptor;

interface

uses
  GlobalRecordsAndEnums, Items;

type
  TDecryptorType = class
    private
      _name: String;
      _id: Integer;
      _probability: Double;
      _me: Integer;
      _pe: Integer;
      _runs: Integer;
    public
      constructor Create(decryptortype: SDecryptorType);

      property Name: String read _name;
      property ID: Integer read _id;
      property Probability: Double read _probability;
      property ME: Integer read _me;
      property PE: Integer read _pe;
      property Runs: Integer read _runs;
  end;

  TDecryptor = class (TNewItem)
    private
// inherited from TNewItem
//      _id: Integer;
//      _name: String[50];
//      _race: ERace;
//      _price: Double;
//      _volume: Double;

      _decryptortype: TDecryptorType;

      function GetProbability: Double;
      function GetME: Integer;
      function GetPE: Integer;
      function GetRuns: Integer;
    public
      constructor Create(Decryptor: SDecryptor; decryptortype: TDecryptorType);

//      property Name: String read GetName;
//      property ID: Integer read _id;
//      property Race: ERace read _race;
//      property Price: Double read _price write _price;
//      property Volume: Double read _volume write _volume;
      property Probability: Double read GetProbability;
      property ME: Integer read GetME;
      property PE: Integer read GetPE;
      property Runs: Integer read GetRuns;
      property DecryptorType: TDecryptorType read _decryptortype;
  end;

implementation

uses
  Classes;

constructor TDecryptorType.Create(decryptortype: SDecryptorType);
begin
  _name := decryptortype.Name;
  _id := decryptortype.ID;
  _probability := decryptortype.Probability;
  _me := decryptortype.ME;
  _pe := decryptortype.PE;
  _runs := decryptortype.Runs;
end;

constructor TDecryptor.Create(Decryptor: SDecryptor; decryptortype: TDecryptorType);
begin
  inherited Create(Decryptor.Name, Decryptor.ID, IT_Decryptor);

//  self._id := Decryptor.ID;
//  self._name := Decryptor.Name;
  self._race := Decryptor.Race;
  self._decryptortype := decryptortype;
  self._price := 0;
  self._volume := 1;
end;

function TDecryptor.GetProbability: Double;
begin
  if (_decryptortype <> nil) then result := _decryptortype.Probability;
end;

function TDecryptor.GetME: Integer;
begin
  if (_decryptortype <> nil) then result := _decryptortype.ME;
end;

function TDecryptor.GetPE: Integer;
begin
  if (_decryptortype <> nil) then result := _decryptortype.PE;
end;

function TDecryptor.GetRuns: Integer;
begin
  if (_decryptortype <> nil) then result := _decryptortype.Runs;
end;

end.
